/**
 *	会员管理
 *
 *	@auth zongjl
 *	@date 2018-07-17
 */
layui.use(['func','form'],function(){
	var form = layui.form,
		func = layui.func,
		$ = layui.$;
	
	if(A=='index') {
		
		//【TABLE列数组】
		var cols = [
				{ type:'checkbox', fixed: 'left' }
				  ,{ field:'id', width:80, title: 'ID', align:'center', sort: true, fixed: 'left' }
				  ,{ field:'realname', width:150, title: '会员名称', align:'center' }
				  ,{ field:'gender_name', width:100, title: '性别', align:'center' }
				  ,{ field:'mobile', width:150, title: '手机号码', align:'center' }
				  ,{ field:'group_name', width:100, title: '会员分组', align:'center' }
				  ,{ field:'city_name', width:200, title: '省市区', align:'center', }
				  ,{ field:'address', width:300, title: '详细地址', align:'center' }
				  ,{ field:'status', width:80, title: '状态', align:'center', templet:"#statusTpl" }
				  ,{ field:'format_add_time', width:200, title:'注册时间', align:'center' }
				  ,{ fixed: 'right', width:100, title: '功能操作区', align:'center', toolbar: '#toolBar' }
			];
		
		//【TABLE渲染】
		func.tableIns(cols,"tableList");

		//【状态开关】
    	form.on('switch(status)', function(obj){
    		//提示
    		layer.tips('温馨提示：关闭后将不在客户终端显示', obj.othis)
    		var status = this.checked ? '1' : '2';
    		
    		$.ajax({
                url:cUrl + "/setStatus",
                dataType:"json",
                type:"POST",
                data:{"id":this.value,"status":status},
                beforeSend:function () {
                    layer.msg('处理中。。。', {
                        icon: 16
                        ,shade: 0.01
                        ,time: 0
                    });
                },
                success:function(res){
                    if(res.success){
                    	//2秒后关闭
                        layer.msg(res.msg,{ icon: 1,time: 1000}, function () {
                        	layer.close(index);
                        });
                    }else{
                        layer.msg(res.msg,{ icon: 5 });
                    }
                }
            });
    		
    	});
		
	}
	
});